var MYAPP = {};
MYAPP.dom = {};

MYAPP.dom.Text = function () {
    this.insert = function (where) {
        var txt = document.createTextNode(this.url);
        where.appendChild(txt);
    };
};

MYAPP.dom.Link = function () {
    this.insert = function (where) {
        var link = document.createElement('a');
        link.href = this.url;
        link.appendChild(document.createTextNode(this.url));
        where.appendChild(link);
    };
};

MYAPP.dom.Image = function () {
    this.insert = function (where) {
        var img = document.createElement('img');
        img.src = this.url;
        where.appendChild(img);
    };
};

MYAPP.dom.factory = function (type) {
    return new MYAPP.dom[type];
};


// use
var o = MYAPP.dom.factory('Link');
o.url = 'http://yunshipei.org';
o.insert(document.getElementById('main'));

var o2 = MYAPP.dom.factory('Image');
o2.url = 'http://www.yunshipei.com/assets/images/logo.png';
o2.insert(document.getElementById('main'));
